package cn.fhkj.bean;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class ResultBean<T> implements Serializable {

	public final static int SUCCESS = 0;
	public final static int FAIL = 1;
	
	private String timestamp = String.valueOf(System.currentTimeMillis());
	/**
	 * 是否成功
	 * 1失败；0成功
	 */
	private int success = SUCCESS;
	/**
	 * 记录
	 */
	private T data;
	/**
	 * 记录总数
	 */
	private long total;
	/**
	 * 总页数
	 */
	private long totalPage;
	/**
	 * 当前页。默认是1
	 */
	private long page = 1L;
	/**
	 * 每页记录数。默认是1
	 */
	private long pageSize = 1L;
	/**
	 * 消息
	 */
	private String msg;
	/**
	 * 状态码
	 */
	private int stCode;

	private List<Field> errors = new ArrayList<>();

	@Override
	public String toString() {
		return org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString(this);
	}

	@Data
	public class Field{
		/**
		 * 哪个字段
		 */
		private String field;
		/**
		 * 出错原因
		 */
		private String msg;
	}
}
